/*
 * $Id: IMagnetMonitorProcessor.java,v 1.1 2009/06/18 19:53:49 afaichun Exp $
 * 
 * Copyright (C) 2008 General Electric Company. All Rights Reserved.
 * 
 * This software is the confidential and proprietary information of the General
 * Electric Company (GE). You shall not disclose this software and shall use it
 * only in accordance with the terms of the license agreement you entered into
 * with GE.
 * 
 * GE MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
 * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
 * NON-INFRINGEMENT. GE SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
 * AS A RESULT OF USING, MODIFYING, OR DISTRIBUTING THIS SOFTWARE OR ITS
 * DERIVATIVES.
 */
package com.ge.healthcare.autosc.processor.magmon;

import com.ge.healthcare.autosc.common.database.pojo.ActTask;
import com.ge.healthcare.autosc.common.exceptions.BasicException;
import com.ge.healthcare.autosc.common.requestData.RequestDataSet;
import com.ge.healthcare.autosc.common.util.dataItem.IASCTextDataItem;
import com.ge.healthcare.autosc.processor.exception.MagnetMonitorProcessorException;
import com.ge.healthcare.autosc.processor.shemjob.reader.ShemTextReader;

public interface IMagnetMonitorProcessor {

    /**
     * Select the site to use for subsequent operations.
     *
     * @param systemId The system identifier of the site to use for subsequent
     *   operations.
     */
    void selectSite( String systemId );

    /**
     * Get the site being selected for operations.
     */
    public String getSite();
    
    /**
     * Select the event to use for subsequent operations.  This is
     *  used primarily for error reporting, allowing the operation in
     *  progress to be noted in case of error.
     *
     * @param majorFunction The major function designator for the event.
     *
     * @param minorFunction The minor function designator for the event.
     *  If there are no minor functions defined for the major function,
     *  use null.
     */
    void selectEvent( String majorFunction, String minorFunction );

    /**
     * Get the major function designated to the event
     * @return
     */
    public String getEventMajorFunction();
    /**
     * Get the minor function designated to the event
     * @return
     */
    public String getEventMinorFunction();
    /**
     * Verify that the current site is registered.
     *
     * @exception AscServiceAbortException If the site is not registered.
     */
    void verifyRegistered() throws MagnetMonitorProcessorException;

    /**
     * Process a single data set.  This provides a single set of
     *  textual data to the magnet monitor.  This method will close
     *  the input reader before returning.
     *
     * @param key The key used to identify the data set being processed.
     *
     * @param inputReader The reader used to read the data set.
     *
     * @exception AscServiceAbortException If an error is detected processing
     *  the data set.
     */
    //void processDataSet(ActTask task, String key, ShemTextReader inputReader)
    //    throws MagnetMonitorProcessorException;

    void processDataSet(ActTask task, String key, ShemTextReader inputReader, RequestDataSet requestDataSet)
        throws BasicException;
    
    /**
     * Process the currently selected event for the currently
     *  selected site.
     *
     * @exception AscServiceAbortException If an error is detected
     *  processing the event.
     */
    void processCurrentEvent() throws MagnetMonitorProcessorException;

    /**
     * Get the specified data item from the site.  This is a convenience
     *  method so only the magnet monitor object directly accesses the site.
     *
     * @param key The key used to identified the data item.
     *
     * @return The specified data item.
     *
     * @exception AscServiceAbortException If no site is currently selected.
     */
    IASCTextDataItem getSiteDataItem( String key )
        throws MagnetMonitorProcessorException;

    /**
     * Perform any clean-up required.  This should be called when done
     *  with the magnet monitor.  This typically involves things like
     *  closing files and removing locks.
     */
    void cleanUp();

    /**
     * Shut down this instance of the service.  This is messaged before the
     *  instance is destroyed.  Open system resources should be closed by
     *  this method.  Only the logging methods of AscServiceHelper are
     *  supported when this method is messaged.
     */
    void shutDownInstance();
}
